import { defineStore } from 'pinia'
import { store } from '/@/store'
import type { AxiosResponse } from 'axios'
import type { Res } from '/@/tool/Res'
import type { Param } from '/@/tool/Param'

import authListService from '/@/api/cn/core/sign/authListService'

import type { AuthList } from '/@/model/cn/core/sign/eo/AuthList'
import type { AuthListQO } from '/@/model/cn/core/sign/qo/AuthListQO'
import type { AuthListVO } from '/@/model/cn/core/sign/vo/AuthListVO'

interface AuthListState {
}

export const useAuthListStore = defineStore({
  id: 'authList',
  state: (): AuthListState => ({
  }),
  getters: {
  },
  actions: {
    save(param: Param<AuthList>): Promise<Res<AuthList>> {
      return new Promise<Res<AuthList>>((resolve, reject) => {
        authListService.save(param).then((res: AxiosResponse<Res<AuthList>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    saveBatch(param: Param<AuthList>): Promise<Res<AuthList>> {
      return new Promise<Res<AuthList>>((resolve, reject) => {
        authListService.saveBatch(param).then((res: AxiosResponse<Res<AuthList>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    update(param: Param<AuthList>): Promise<Res<AuthList>> {
      return new Promise<Res<AuthList>>((resolve, reject) => {
        authListService.update(param).then((res: AxiosResponse<Res<AuthList>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    updateBatch(param: Param<AuthList>): Promise<Res<AuthList>> {
      return new Promise<Res<AuthList>>((resolve, reject) => {
        authListService.updateBatch(param).then((res: AxiosResponse<Res<AuthList>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    remove(param: Param<AuthList>): Promise<Res<AuthList>> {
      return new Promise<Res<AuthList>>((resolve, reject) => {
        authListService.remove(param).then((res: AxiosResponse<Res<AuthList>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    removeBatch(param: Param<AuthList>): Promise<Res<AuthList>> {
      return new Promise<Res<AuthList>>((resolve, reject) => {
        authListService.removeBatch(param).then((res: AxiosResponse<Res<AuthList>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    count(param: Param<AuthListQO>): Promise<Res<AuthList>> {
      return new Promise<Res<AuthList>>((resolve, reject) => {
        authListService.count(param).then((res: AxiosResponse<Res<AuthList>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pk(param: Param<AuthListQO>): Promise<Res<AuthList>> {
      return new Promise<Res<AuthList>>((resolve, reject) => {
        authListService.pk(param).then((res: AxiosResponse<Res<AuthList>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    query(param: Param<AuthListQO>): Promise<Res<AuthList>> {
      return new Promise<Res<AuthList>>((resolve, reject) => {
        authListService.query(param).then((res: AxiosResponse<Res<AuthList>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    paging(param: Param<AuthListQO>): Promise<Res<AuthList>> {
      return new Promise<Res<AuthList>>((resolve, reject) => {
        authListService.paging(param).then((res: AxiosResponse<Res<AuthList>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    countVo(param: Param<AuthListQO>): Promise<Res<AuthListVO>> {
      return new Promise<Res<AuthListVO>>((resolve, reject) => {
        authListService.countVo(param).then((res: AxiosResponse<Res<AuthListVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pkVo(param: Param<AuthListQO>): Promise<Res<AuthListVO>> {
      return new Promise<Res<AuthListVO>>((resolve, reject) => {
        authListService.pkVo(param).then((res: AxiosResponse<Res<AuthListVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    queryVo(param: Param<AuthListQO>): Promise<Res<AuthListVO>> {
      return new Promise<Res<AuthListVO>>((resolve, reject) => {
        authListService.queryVo(param).then((res: AxiosResponse<Res<AuthListVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pagingVo(param: Param<AuthListQO>): Promise<Res<AuthListVO>> {
      return new Promise<Res<AuthListVO>>((resolve, reject) => {
        authListService.pagingVo(param).then((res: AxiosResponse<Res<AuthListVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
  },
})

export function useAuthListStoreWithout() {
  return useAuthListStore(store)
}
